package com.oracle.controller;

import com.oracle.application.vo.R;
import com.oracle.feign.CartFeign;

import com.oracle.utils.HttpUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/cart")
public class CartController {
        @Autowired
        private CartFeign cartFeign;

        @PostMapping("/addCart")
        public R addCart(@RequestParam(value = "bookId") Integer bookId, @RequestParam(value = "buyNum") Integer buyNum){
                HttpServletRequest httpServletRequest = HttpUtils.getHttpServletRequest();
                String token = httpServletRequest.getHeader("token");
                return cartFeign.addCart(bookId, buyNum,token);
        }
        @GetMapping("/delCart")
        public R delCart(@RequestParam(value = "bookId") Integer bookId){
                return cartFeign.delCart(bookId);
        }
}
